package com.example;

import javax.swing.*;
import java.awt.*;

public class SimpleTextDisplay extends WeatherDisplay {
    private JLabel weatherInfo;
    
    public SimpleTextDisplay() {
        setLayout(new BorderLayout());
        weatherInfo = new JLabel("", JLabel.CENTER);
        weatherInfo.setFont(new Font("微软雅黑", Font.PLAIN, 16));
        add(weatherInfo, BorderLayout.CENTER);
    }
    
    @Override
    public void updateWeather(WeatherData data) {
        String html = String.format("<html><div style='text-align:center;'>" +
                "<h2>%s</h2>" +
                "<p>当前温度: %.1f°C (体感: %.1f°C)</p>" +
                "<p>天气状况: %s</p>" +
                "<p>湿度: %d%%</p>" +
                "<p>风速: %.1f m/s</p></div></html>",
                data.getLocation(), data.getTemperature(), data.getFeelsLike(),
                data.getDescription(), data.getHumidity(), data.getWindSpeed());
        
        weatherInfo.setText(html);
    }
}